package com.abou.model.common.product;

import com.abou.model.common.Entity;

/**
 * @author vvvq5150
 */
public class Sale extends Entity {
  
  private static final long serialVersionUID = 1L;
  private Integer percent;
  private Double price;
  private Double salePrice;
  private Boolean inSale;
  private Double reduction;
  
  /**
   * The default constructor
   */
  public Sale() {

    super();
  }
  
  /**
   * The constructor
   * 
   * @param percent The sale percent
   * @param price The product initial price
   */
  public Sale(Integer percent, Double price) {

    super();
    this.percent = percent;
    this.price = price;
    
    salePrice = computeSalePrice(percent, price);
  }
  
  /**
   * Computes the sale price.
   * 
   * @param pricePercent The sale percent
   * @param initialPrice The product initial price
   * @return The sale price
   */
  public Double computeSalePrice(Integer pricePercent, Double initialPrice) {

    double sale = 0;
    reduction = (pricePercent * initialPrice) / 100;
    sale = initialPrice - reduction;
    
    return sale;
  }
  
  /**
   * @return The sale percent
   */
  public Integer getPercent() {

    return percent;
  }
  
  /**
   * @param percent The new sale percent
   */
  public void setPercent(Integer percent) {

    this.percent = percent;
  }
  
  /**
   * @return The initial product price
   */
  public Double getPrice() {

    return price;
  }
  
  /**
   * @param price The product price new value
   */
  public void setPrice(Double price) {

    this.price = price;
  }
  
  /**
   * @param inSale new value
   */
  public void setInSale(Boolean inSale) {

    this.inSale = inSale;
  }
  
  /**
   * @return Whether the product is in sale or not.
   */
  public Boolean isInSale() {

    return inSale;
  }
  
  /**
   * @param reduction The reduction
   */
  public void setReduction(Double reduction) {

    this.reduction = reduction;
  }
  
  /**
   * @return The price reduction
   */
  public Double getReduction() {

    return reduction;
  }
  
  public void setSalePrice(Double salePrice) {

    this.salePrice = salePrice;
  }
  
  public Double getSalePrice() {

    return salePrice;
  }
}
